package com.lap.framework.generator.shared.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.Getter;

@Getter
public enum ValidationType {
  REQUIRED("required"),
  RANGE("range"),
  MAX_LENGTH("max.length"),
  ;

  private final String suffix;

  private static final Map<String, ValidationType> BY_SUFFIX =
      Arrays.stream(values())
          .collect(Collectors.toMap(ValidationType::getSuffix, Function.identity()));

  ValidationType(String suffix) {
    this.suffix = suffix;
  }

  public static ValidationType valueOfSuffix(String suffix) {
    return BY_SUFFIX.get(suffix);
  }
}
